package com.example.prueba2;

import java.io.IOException;

import org.ksoap2.SoapEnvelope;
import org.ksoap2.serialization.PropertyInfo;
import org.ksoap2.serialization.SoapObject;
import org.ksoap2.serialization.SoapPrimitive;
import org.ksoap2.serialization.SoapSerializationEnvelope;
import org.ksoap2.transport.HttpResponseException;
import org.ksoap2.transport.HttpTransportSE;
import org.xmlpull.v1.XmlPullParserException;

import android.os.AsyncTask;
import android.os.Bundle;
import android.app.Activity;
import android.view.Menu;
import android.view.MotionEvent;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;

public class MainActivity extends Activity {

	String sum1 = "";
	int sum2 = 0;
	EditText op1;
	EditText op2; 
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.activity_main);
		//Button btnSuma = (Button)findViewById(R.id.btnSuma);
		op1 = (EditText)findViewById(R.id.op1);
		op2 = (EditText)findViewById(R.id.op2);
		
		findViewById(R.id.btnSuma).setOnTouchListener(
				new View.OnTouchListener() {
					
					@Override
					public boolean onTouch(View v, MotionEvent event) {
						sum1 = op1.getText().toString();
						//sum2 = Integer.parseInt(op2.getText().toString());
						suma();
						return false;
					}
				
				});
	}

	@Override
	public boolean onCreateOptionsMenu(Menu menu) {
		// Inflate the menu; this adds items to the action bar if it is present.
		getMenuInflater().inflate(R.menu.main, menu);
		return true;
	}
	
	public void suma(){
		CallWs ws = new CallWs();
		ws.execute(sum1);
	}
	
	private class CallWs extends AsyncTask<String, String, String>{

		@Override
		protected String doInBackground(String... params) {
			String resp ="";
			logica l = new logica();
			resp = l.sum(params[0]);
			return resp;
	}
	}

}
